<?php

/**
 * Created by PhpStorm.
 * User: Eric
 * Email: 13522679763@163.com
 * Date: 2018/8/3
 * Time: 21:17
 */
namespace  app\common\lib\exception;
use think\exception\Handle;

class Exception extends Handle
{
    public  $httpCode = 500;
    public  function render(\Exception $e)
    {
        $data=[
            'status'=>0,
            'msg'=>$e->getMessage(),
            'data'=>'请求失败'
        ];
        if($e instanceof  ApiException){
            $this->httpCode = $e->httpCode;
        }
        return  json($data,$this->httpCode);
    }
}